package com.ailot.cloud.base.data.handler;

import com.ailot.cloud.base.security.utils.SecurityUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

@Configuration
public class UserMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        String currentUserId = SecurityUtil.getId();
        this.setFieldValByName("createId",  currentUserId,metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        String currentUserId = SecurityUtil.getId();
        this.setFieldValByName("createId",  currentUserId,metaObject);
    }

}
